package dingcan;
import java.util.Scanner;
public class Check extends  Indent{
    Scanner scanner = new Scanner(System.in);
    int i = 0;

    //查看餐袋
    public void ChaKan() {
        System.out.println("你的订单信息如下:");
        System.out.println("订单编号"+"\t"+"点餐人"+"\t"+"菜名"+"\t"+"份数"
                +"\t"+"总价"+"\t"+"送餐时间"+"\t"+"送餐地址"+"\t"+"签收状态");
        try {
            for (i=0;i< File.person.length;i++){
                if (File.person[i].getUserName()!=null){
                    File.person[i].setUserCaiName(File.indent.getDishName());
                    File.person[i].setUserCaiNum(File.indent.getCopies());
                    File.person[i].setUserAllPrice(File.indent.getAllPrice());
                    File.person[i].setUserTime(File.indent.getTime());
                    setNumber(i+1);

                    System.out.println(getNumber()+"\t"+File.person[i].getUserName()+"\t\t"+File.person[i].getUserCaiName()
                            +"\t"+File.person[i].getUserCaiNum()+"\t"+File.person[i].getUserAllPrice()
                            +"\t"+File.person[i].getUserTime()+"\t"+File.person[i].getUserAddress()
                            +"\t"+File.person[i].getUserTag());
                }else {
                    break;
                }

            }
        }catch (Exception e){
            System.out.println();
        }
        System.out.println();

    }

    //签收订单
    public void QianShou() {
        ChaKan();
        System.out.println("..................");
        System.out.println("请选择要签收的订单:");
        int sign = scanner.nextInt();
        if (sign==getNumber()){
            File.person[i-1].setUserTag(1);
            System.out.println(i+"号订单已签收!");
        }else {
            System.out.println("没有该订单!");
        }
        System.out.println();
    }

    //删除订单
    public void ShanChu() {
        ChaKan();
        System.out.println(".................");
        System.out.println("请选择要删除的订单:");
        int del = scanner.nextInt();
        if (File.person[i-1].getUserTag()==0){
            System.out.println("该订单未完成,不能删除!");
        }else {
            if (del==getNumber()){
                File.person[i-1]=null;
                File.person[i-1]=File.person[i];
                System.out.println(i+"号订单已删除!");
            }
        }
        System.out.println();
    }


    //点赞菜品
    public void DianZan(){
        int k;
        System.out.println("序号"+"\t\t"+"菜名"+"\t\t\t"+"价格"+"\t\t"+"点赞数");
        for (k=0;k< File.menu.length;k++){
            System.out.println(File.menu[k].getNumber()+"\t\t"+File.menu[k].getDishName()
                    +"\t\t"+File.menu[k].getPrice()+"\t\t"+File.menu[k].getLike());
        }
        System.out.println("请选择要点赞的菜品:");
        int like = scanner.nextInt();
        for (k=0;k< File.menu.length;k++){
            if (like == File.menu[k].getNumber()){
                File.menu[k].setLike(File.menu[k].getLike()+1);
                System.out.println("点赞成功!");
            }
        }
        System.out.println();

    }
}

